﻿using FieldTools.Client.Command;
using FieldTools.Client.View.Base;
using FieldTools.Client.Entity;
using HandyControl.Controls;
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MessageBox = HandyControl.Controls.MessageBox;
using Window = HandyControl.Controls.Window;

namespace FieldTools.Client.View.Control
{
    /// <summary>
    /// MutViewControl.xaml 的交互逻辑
    /// </summary>
    public partial class MutViewControl : UserControl
    {
        public MutViewControl()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(MutViewControl), null);

        /// <summary>
        /// 说明内容
        /// </summary>
        public string StateContent
        {
            get { return (string)GetValue(StateContentProperty); }
            set { SetValue(StateContentProperty, value); }
        }
        public static readonly DependencyProperty StateContentProperty =
            DependencyProperty.Register("StateContent", typeof(string), typeof(MutViewControl), null);

        /// <summary>
        /// 展示为页面的用户控件依赖属性
        /// </summary>
        public List<ControlCon> MutControls
        {
            get { return (List<ControlCon>)GetValue(MutControlsProperty); }
            set { SetValue(MutControlsProperty, value); }
        }
        /// <summary>
        /// 
        /// </summary>
        public static readonly DependencyProperty MutControlsProperty =
            DependencyProperty.Register("MutControls", typeof(List<ControlCon>), typeof(MutViewControl), null);

        private void Card_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Card card = (Card)sender;
            var da = (ControlCon)card.Footer;
            //MessageBox.Show("双击了卡片:" + da.Title);
            //MetroWindow window = new();
            //window.DataContext = window;
            //window.Content = WindowControlManager.GetShow(da.Name, da.VMName);
            //window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            //window.Width = 1080;
            //window.Height = 720;
            //window.Title = da.Title;
            //window.Show();
            //window.Closed += Window_Closed;
            if(da != null && da.Name!=null)
            {
                WindowManager.Show(da.Name, null);
            }
        }
    }
    /// <summary>
    /// 展示为页面用户控件传递实体
    /// </summary>
    public class ControlCon
    {
        /// <summary>
        /// 标题
        /// </summary>
        public string? Title { get; set; }
        /// <summary>
        /// 控件名
        /// </summary>
        public string? Name { get; set; }
        /// <summary>
        /// 视图模型名
        /// </summary>
        public string? VMName { get; set; }
        /// <summary>
        /// vm视图模型实体
        /// </summary>
        public object? VMObject { get; set; }
        /// <summary>
        /// 预览图路径
        /// </summary>
        public string? ImgPath { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }
        /// <summary>
        /// 其他
        /// </summary>
        public string? Other { get; set; }
    }
}
